import { ScjcService } from './scjc.service';
import {
  Controller,
  Get,
  Post,
  UploadedFile,
  UseInterceptors,
} from '@nestjs/common';
import { ApiOperation } from '@nestjs/swagger';
import { JwtNoVerify } from '../../decorators';
import { FileInterceptor } from '@nestjs/platform-express';

@Controller('scjc')
export class ScjcController {
  constructor(private readonly _scjcService: ScjcService) {}

  // 模拟发送sse数据
  @Get('getAllData')
  @JwtNoVerify()
  @ApiOperation({ summary: '获取当前工艺流程的数据' })
  async getAllData() {
    return await this._scjcService.getAllData();
  }

  // 保存redis
  @Post('saveRedis')
  @JwtNoVerify()
  async setRedisData() {
    return await this._scjcService.setRedisData();
  }

  // 获取redis数据
  @Get('getRedis')
  @JwtNoVerify()
  async getRedisData() {
    return this._scjcService.getRedisData();
  }

  // 对接三方接口 请求数据写法
  @Get('getDingDingData')
  @JwtNoVerify()
  async getDingDingData() {
    return this._scjcService.getDingDingData();
  }

  // 下载模板
  @Get('excel-template')
  @JwtNoVerify()
  async DownLoadExcelTemplate() {
    return this._scjcService.downLoadExcelTemplate();
  }

  // 测试表格导出
  @Get('excel-export')
  @JwtNoVerify()
  async ExcelExport() {
    return this._scjcService.excelExport();
  }

  // 测试表格导入
  @Post('excel-import')
  @JwtNoVerify()
  @UseInterceptors(FileInterceptor('file'))
  async ExcelImport(@UploadedFile() file: Express.Multer.File) {
    return this._scjcService.excelImport(file);
  }
}
